<template>
  <div>
    123
    {{text}}
    <slot name="a" :data="data"></slot>
  </div>
</template>

<script>
import {
  defineComponent,
  getCurrentInstance,
  inject,
  onMounted,
  reactive,
  toRefs,
} from "vue";
export default defineComponent({
  setup() {
    const a = inject("text");
    const b = inject("textChange");
    const slot = reactive({data:'123'})
    const self = getCurrentInstance();
    onMounted(() => {
      b(1);
      console.log(self.ctx);
      // getCurrentInstance() 表示 vue2的this
      // $ELEMENT: (...)
      // $alert: (...)
      // $attrs: (...)
      // $confirm: (...)
      // $data: (...)
      // $el: (...)
      // $emit: (...)
      // $forceUpdate: (...)
      // $http: (...)
      // $loading: (...)
      // $message: (...)
      // $messageBox: (...)
      // $msgbox: (...)
      // $nextTick: (...)
      // $notify: (...)
      // $options: (...)
      // $parent: (...)
      // $prompt: (...)
      // $props: (...)
      // $refs: (...)
      // $root: (...)
      // $router: (...)
      // $slots: (...)
      // $store: (...)
      // $watch: (...)
      self.ctx.$message({
        type: "success",
        message: "122",
      });
      // textChange()
    });
    return {
      ...toRefs(a),
      ...toRefs(slot),
      b,
    };
  },
});
</script>

<style>
</style>